package xx.pro.producer;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
import xx.pro.common.MessageInfo;

import javax.annotation.Resource;

@Component
public class ProducerSeq {
    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * 根据id，将消息顺序发送到对应的队列
     * @param id  业务id
     * @param msg 业务信息
     */
    public void send(int id, String msg) {
        MessageInfo message = new MessageInfo(id, msg);
        rabbitTemplate.convertAndSend("direct_seq", String.valueOf(id % 2 + 1), message.toString());
    }
}
